/*********************************************************************
 *
 *  MODULE: MWIN.CPP
 *  AUTHOR: BRIAN M. WORKMAN
 *  START DATE: 3/13/2006 8:41:53 PM
 *
 **********************************************************************/

#ifndef MWIN_H
#define MWIN_H

#include <QtNetwork>
#include <QtGui>

#include "ui_config.h"

class ConfigDialog : public QDialog
{
    Q_OBJECT
public:
    ConfigDialog(QWidget *parent = 0);
    void enableProxy(bool);
    void setProxyAddress(QString address);
    void setProxyPort(int port);
    void setProxyUsername(QString user);
    void setProxyPassword(QString password);
    void setAutoClipboard(bool yn);
    bool proxy() const;
    QString proxyAddress() const;
    int proxyPort() const;
    QString proxyUsername() const;
    QString proxyPassword() const;
    bool autoClipboard() const;
    
   
private:
    Ui::dlgConfig ui;
};

class MWin : public QMainWindow
{
    Q_OBJECT

public:
    MWin(QWidget *parent = 0, Qt::WFlags flags = 0);
    
private:
    QHttp *http;
    QDateTimeEdit *dateTime;
    QToolButton *fetch;
    QToolButton *config;
    QLineEdit *results;
    
    QAction *actFetch;
    QAction *actFetch2;
    QAction *actConfig;
    QAction *actCancel;

    int httpGetId;
    bool httpRequestAborted;
    QBuffer *data;
    ConfigDialog *window;
    
    void readSettings();
    void writeSettings();
    
    QString m_proxy_address;
    int m_proxy_port;
    QString m_proxy_username;
    QString m_proxy_password;
    bool m_proxy;
    bool m_auto_clipboard;
    bool isStandardTime(QDateTime);
    
private slots:
    void doFetch();
    void doConfig();
    void cancelDownload();
    void httpRequestFinished(int requestId, bool error);
    void readResponseHeader(const QHttpResponseHeader &responseHeader);
    void stateChanged(int s);
    void enableInput(bool);
};

#endif  // MWIN_H
